package com.scrx.ymg.action;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.google.gson.Gson;
import com.scrx.ymg.entity.AgentHot;
import com.scrx.ymg.service.agent.IAgentService;

@Controller
@RequestMapping("/hotProductAction")
public class HotProductAction {
	
	 @Autowired
     private IAgentService agents;
	
	/**
	 * 代理商设置爆款
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/setHotProduct",produces = "text/json;charset=UTF-8")
	public String setHotProduct(MultipartFile Thumbnail,MultipartFile banner,MultipartFile bigpicFile,MultipartFile hotDetailFile,AgentHot hot){
		return agents.saveAgentHot(hot,Thumbnail,banner,bigpicFile,hotDetailFile);
	}
	
	/**
	 * 代理商更新爆款
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/updateHotProduct",produces = "text/json;charset=UTF-8")
	public String updateHotProduct(MultipartFile Thumbnail,MultipartFile banner,MultipartFile bigpicFile,MultipartFile hotDetailFile,AgentHot hot){
		return agents.updateAgentHot(hot,Thumbnail,banner,bigpicFile,hotDetailFile);
	}
	
	/**
	 * 代理商查询爆款
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/getHotProduct",produces = "text/json;charset=UTF-8")
	public String getHotProduct(AgentHot hot,int pageNum,int pageCount){
		Map<Object, Object> map = agents.getHotProduct(hot,pageNum,pageCount);
		Gson gson = new Gson();
		return gson.toJson(map);
	}
	
	/**
	 * 总部查询爆款
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/getHotProductHead",produces = "text/json;charset=UTF-8")
	public String getHotProductHead(AgentHot hot,int pageNum,int pageCount,String agentRegion){
		Map<Object, Object> map = agents.getHotProduct(hot,pageNum,pageCount,agentRegion);
		Gson gson = new Gson();
		return gson.toJson(map);
	}
	
	/**
	 * 代理商删除爆款
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/deleteHotProduct",produces = "text/json;charset=UTF-8")
	public String deleteHotProduct(int hotId){
		String msg = agents.deleteHotProduct(hotId);
		return msg;
	}
	
	/**
	 * 上下架爆款
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value ="/putawayHotProduct",produces = "text/json;charset=UTF-8")
	public String putawayHotProduct(int hotId,int putaway){
		String msg = agents.putawayHotProduct(hotId,putaway);
		return msg;
	}

}
